package com.tc.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tc.service.BeddetailsService;
import com.tc.utils.ResultVo;
import com.tc.dto.BedDetailsDTO;
import com.tc.dto.ExchangeDTO;
import com.tc.domain.Beddetails;
import com.tc.vo.BedDetailsVo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jcd
 * @since 2025-06-23
 */
@RestController
@RequestMapping("/beddetails")
@Api(tags = "床位详情")
@CrossOrigin
public class BeddetailsController {
    @Autowired
    private BeddetailsService beddetailsService;

    @GetMapping("/listBedDetailsVoPage")
    @ApiOperation("床位详情列表动态查询（分页）")
    public ResultVo<Page<BedDetailsVo>> listBedDetailsVoPage(BedDetailsDTO bedDetailsDTO) throws Exception {
        return beddetailsService.listBedDetailsVoPage(bedDetailsDTO);
    }

    @PostMapping("/updateBedDetails")
    @ApiOperation("更新床位使用详情-只能修改床位使用结束时间")
    public ResultVo updateBedDetails(Beddetails beddetails) throws Exception {
        beddetailsService.updateById(beddetails);
        return ResultVo.ok("编辑成功");
    }

    @PostMapping("/exchangeBed")
    @ApiOperation("床位交换")
    public ResultVo exchangeBed(ExchangeDTO exchangeDTO) throws Exception {
        return beddetailsService.exchangeBed(exchangeDTO);
    }

    @GetMapping("/delBedDetails")
    @ApiOperation("删除记录")
    public ResultVo delBedDetails(Integer id) throws Exception {
        beddetailsService.removeById(id);
        return ResultVo.ok("删除成功");
    }

}

